/**
 * 
 */
package org.braketester.model;

import java.util.ArrayList;

import org.braketester.model.filters.RunnableFilter;

/**
 * @author LAP
 *
 */
public class RawDataReader extends Thread {
	private ArrayList<RunnableFilter> filters;
	private RawData data;
	/**
	 * 
	 * @param data данные которые раздербаниваем
	 * @param increment 0 - 7 
	 */
	public RawDataReader(RawData data, ArrayList<RunnableFilter> filters) {
		if (filters == null) throw new IllegalArgumentException("Filters must be not null");
		if (data == null) throw new IllegalArgumentException("data must be not null");
		this.data = data;
		this.filters = filters;
	}
	
	@Override
	public void run() {
		while(true) {
			ArrayList<Double> values = data.getLoaded();
			int i = 0;
			for(Double value : values) {
				filters.get(i).addValue(value);
				if (i < filters.size()) i++;
				else i = 0;
			}
		}
	}
}
